/** include config.h **/
#include "config.h"
#ifdef ENABLE_ORACLE
//#include <oci1.h>
#include <iostream>
#include <string>
#include <map>

#include "Database.h"
#include <oci.h>
/**
 * to Oracle Database connecting
 **/
class OracleDatabase : public Database{
public:
    /** Constructor and Database Connection **/

	OracleDatabase(std::string *host, std::string *port, std::string *database, std::string *user, std::string *password);
	virtual ~OracleDatabase();
	bool isConnected(std::string database);

	/** Query **/
    PQuery query(std::string sqlQuery);
	std::string getTableInfoSQL(std::string *database, std::string *schema, std::string *table);
	size_t getTableSize(std::string *database, std::string *schema, std::string *table);

	/** List Databases, Schemata and Tables **/
	PQuery listDatabases();
	PQuery listSchemata(std::string *database);
    PQuery listTables(std::string *database, std::string *schema);

    /** Exists check**/
    bool database_exists(std::string database);
    bool schema_exists(std::string database, std::string schema);
    bool table_exists(std::string database, std::string schema, std::string table);

    /** Other Query **/
    void rename(std::string oldname, std::string newname);

	void escapeString(std::string str);
	void error(std::string errormsg);

private:
    OCIServer	*server;
	OCISession	*session;
	OCIEnv		*env;
	OCIError	*error;
	OCISvcCtx	*server_context;
};

class OracleQuery : public AbstractQuery{
	OracleQuery(Database *dbc, std::string database, std::string sqlQuery);
	virtual ~OracleQuery();
	DataRow* fetch();
};
#endif
